﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Win32;

namespace WPFTrees.PropertyDialogs
{
    /// <summary>
    /// Interaction logic for ImagePropertyDlg.xaml
    /// </summary>
    public partial class ImagePropertyDlg : Window
    {
        public ImagePropertyDlg()
        {
            InitializeComponent();
        }

        public ImageSource Image
        {
            get { return image.Source; }
            set { image.Source = value; }
        }

        private void miCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void miOK_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }

        private void btnChange_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.DefaultExt = ".bmp";
            if (dlg.ShowDialog() == true)
            {
                image.Source = new BitmapImage(new Uri(dlg.FileName));
            }
        }
    }
}
